/*
 * File:   utility_data_structures_test.hpp
 * Author: picci
 *
 * Created on 5 settembre 2010, 13.59
 */
#define BOOST_TEST_MODULE pipeline facility test
#include <boost/test/included/unit_test.hpp>

#include "common/utility_data_structures.h"

struct utility_data_structures_fixture{
    utility_data_structures_fixture(){
        key_key_name = "keyNameValue";
        key_namespace = "keyNamespace";
        result_key_string = key_namespace                +
                            gestface::Key::KEY_SEPARATOR +
                            key_key_name                 ;

        // ****** Key Initializations ******************************************
        key = new gestface::Key();
        key->set_key(key_namespace, key_key_name);

        copy_key = new gestface::Key(*key);

        assigned_key = new gestface::Key();
        assigned_key2 = new gestface::Key();

        /* Double assignement is used to test if operator= correctly returns the self
         * reference
         */
        *assigned_key2 = *assigned_key = *key;
        // ---------------------------------------------------------------------

        // ****** IOKey Initializations ****************************************
        io_key = new gestface::IOKey();
        io_key->set_key(key_namespace, key_key_name);
        io_key->setType(typeid(key_namespace));

        io_copy_key = new gestface::IOKey(*io_key);

        io_assigned_key = new gestface::IOKey();
        io_assigned_key2 = new gestface::IOKey();

        /* Double assignement is used to test if operator= correctly returns the self
         * reference
         */
        *io_assigned_key2 = *io_assigned_key = *io_key;

        io_key2 = new gestface::IOKey();
        io_key2->set_key(key_namespace, key_key_name);
        io_key2->setType(typeid(int));
        // ---------------------------------------------------------------------
    }

    ~utility_data_structures_fixture(){
        delete key;
        delete copy_key;
        delete assigned_key;
        delete assigned_key2;

        delete io_key;
        delete io_key2;
        delete io_copy_key;
        delete io_assigned_key;
        delete io_assigned_key2;
    }

    gestface::Key *key, *copy_key, *assigned_key, *assigned_key2;
    gestface::IOKey *io_key, *io_key2, *io_copy_key, *io_assigned_key, *io_assigned_key2;

    std::string key_key_name;
    std::string key_namespace;
    std::string result_key_string;
};

BOOST_FIXTURE_TEST_SUITE(utility_data_structures_test, utility_data_structures_fixture)

BOOST_AUTO_TEST_SUITE(Key_tests)

BOOST_AUTO_TEST_CASE(Key_constructors_test){
    BOOST_CHECK(key->get_key() == result_key_string);
    BOOST_CHECK(*copy_key == *key);
    BOOST_CHECK(*assigned_key == *key);
    BOOST_CHECK(*assigned_key2 == *key);
}

BOOST_AUTO_TEST_CASE(IOKey_constructors_test){
    BOOST_CHECK(io_key->get_key() == result_key_string);
    BOOST_CHECK(*io_key2 != *io_key);
    BOOST_CHECK(*io_copy_key == *io_key);
    BOOST_CHECK(*io_assigned_key == *io_key);
    BOOST_CHECK(*io_assigned_key2 == *io_key);
}

BOOST_AUTO_TEST_SUITE_END()

BOOST_AUTO_TEST_SUITE_END()

